#ifndef UI_BENCHMARKWIDGET_HPP
#define UI_BENCHMARKWIDGET_HPP

#include <QWidget>
#include <QList>
#include <QString>
#include <QFuture>
#include <QFutureWatcher>
class QTextEdit;
class QLabel;

namespace cl {

    class Device;
    class Benchmark;
}

namespace ui {

    class BenchmarkWidget : public QWidget {

        Q_OBJECT

    public:
        BenchmarkWidget(const cl::Device &device, QWidget *parent = 0);
        ~BenchmarkWidget(void);

        void buildProgram(void);

    signals:

        void isRunning(bool);

    private slots:

        void onProgramBuilt(int status, const char *options, const char *log);
        void onBenchmarkDone(void);
        void onContextError(const char *errorInfo);

    private:

        QString formatGFlops(double value);
        void runBenchmark(void);
        void runFloatBenchmark(void);
        void runDoubleBenchmark(void);

        QFuture<void>        futureBenchmark;
        QFutureWatcher<void> futureBenchmarkWatcher;

        QList<QLabel *> floatValues;
        QList<QLabel *> doubleValues;
        QTextEdit *textEdit;
        cl::Benchmark *benchmark;
        bool hasDoubleOption;
    };
}

#endif // UI_BENCHMARKWIDGET_HPP
